package com.cxg.fairy.ec.main.personal.message;

import android.graphics.Color;
import android.support.v7.widget.AppCompatTextView;

import com.cxg.fairy.ui.recycler.MultipleFields;
import com.cxg.fairy.ui.recycler.MultipleItemEntity;
import com.cxg.fairy.ui.recycler.MultipleRecyclerAdapter;
import com.cxg.fairy.ui.recycler.MultipleViewHolder;
import com.cxg.fairy.util.log.LatteLogger;
import com.diabin.latte.ec.R;
import com.joanzapata.iconify.widget.IconTextView;

import java.util.List;

/**
 * Created by CFairy
 */

public class MessageCenterFundsAdapter extends MultipleRecyclerAdapter {

    protected MessageCenterFundsAdapter(List<MultipleItemEntity> data) {
        super(data);
        addItemType(MessageItemType.MESSAGE_CENTER_TYPE, R.layout.item_message_list);
        addItemType(MessageItemType.MESSAGE_CENTER_ORDERS, R.layout.item_message_list);
        addItemType(MessageItemType.MESSAGE_CENTER_PROMOTION, R.layout.item_message_list);
        addItemType(MessageItemType.MESSAGE_CENTER_SYSTEM, R.layout.item_message_list);
    }

    @Override
    protected void convert(final MultipleViewHolder holder, final MultipleItemEntity entity) {
                final String title = entity.getField(MultipleFields.NAME);
                final String content = entity.getField(MultipleFields.TAG);
                final String date = entity.getField(MultipleFields.TEXT);
                final int id = entity.getField(MultipleFields.ID);
                final int itemType = entity.getField(MultipleFields.ITEM_TYPE);

                final IconTextView imgIconText = holder.getView(R.id.itv_msg_item_img);
                final AppCompatTextView titleText = holder.getView(R.id.tv_msg_item_title);
                final AppCompatTextView contentText = holder.getView(R.id.tv_msg_item_content);
                final AppCompatTextView dateText = holder.getView(R.id.tv_msg_item_date);
                switch (itemType) {
                    case 1:
                        imgIconText.setText("{icon-msg-center-my-funds}");
                        break;
                    case 2:
                        imgIconText.setText("{icon-msg-center-order-notice}");
                        imgIconText.setBackgroundColor(Color.parseColor("#5884ff"));
                        break;
                    case 3:
                        imgIconText.setText("{icon-msg-center-promote}");
                        imgIconText.setBackgroundColor(Color.parseColor("#6e32fc"));
                        break;
                    case 4:
                        imgIconText.setText("{icon-msg-center-os-notice}");
                        imgIconText.setBackgroundColor(Color.parseColor("#403f40"));
                        break;
                    default:
                        imgIconText.setText("{icon-msg-center-my-funds}");
                        break;
                }
                titleText.setText(title);
                contentText.setText(content);
                dateText.setText(date);
    }

}
